package com.dems.domain;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.dems.util.JDBCUtils;



public class Test {
	public static void main(String[] args) {
		Connection conn = null;
	    PreparedStatement ps = null;
	    ResultSet rs = null;
		try {
            conn = JDBCUtils.getConnection();
            String sql = "select * from student where student_name=?";
            ps = conn.prepareStatement(sql);
            ps.setString(1,"李三");
            rs = ps.executeQuery();
            if(rs.next()){
                Student student = new Student();
                student.setStudentId(rs.getInt("student_id"));
                student.setStudentName(rs.getString("student_name"));
                student.setStudentPassword(rs.getString("student_password"));
                student.setStudentDormitory(rs.getString("student_dormitory"));
                student.setBuildingId(rs.getString("building_id"));
                student.setStudentPhone(rs.getString("student_phone"));
                System.out.println(student.toString());
            }else{
                System.out.println("错误");
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JDBCUtils.close(conn,ps,rs);
        }
	}
}
